//
//  main.c
//  electronic_clock
//
//  Created by fukai on 2018/10.
//  Copyright © 2018年 赛博智能车实验室. All rights reserved.
//

#include "tick_timer.h"
#include "key.h"
#include "led.h"
#include "oled.h"
#include "timer_interrupt.h"
#include "clock_os.h"
#include "beep.h"
#include "at24cxx.h"

typedef enum
{
	CLOCK_TIME_ANALYSIS = 0,//时间分析，判断是否为闰年
	CLOCK_USER_INTERFACE,//用户界面显示
}SmcStatusNode;


void Init(void)
{
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组2
	DelayInit();	//滴答定时器初始化
	At24cxxIICInit();
	OledInit();
	KeyInit();
	LedInit();
	BeepInit();
	Tim2IntInit(9,7199);	//1ms一次中断  72000000/7200=10kHZ  
}

int main(void)
{
	Init();
	SmcStatusNode SmcStatus	= CLOCK_TIME_ANALYSIS;	//初始化系统状态机
	
	while(1)
	{
		switch(SmcStatus)
		{
			case CLOCK_TIME_ANALYSIS:	//时间分析，判断是否为闰年
				
				SmcStatus = CLOCK_USER_INTERFACE;	//进入下一状态
				break;
			
			case CLOCK_USER_INTERFACE:	//用户界面显示
				
				UserInterface();
			
				SmcStatus = CLOCK_TIME_ANALYSIS;	
				break;
		}
	}
}


